package com.yby.mall.storage.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.yby.common.utils.R;
import com.yby.mall.storage.entity.PurchaseDetailEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yby.common.utils.PageUtils;
import com.yby.common.utils.Query;

import com.yby.mall.storage.dao.PurchaseDao;
import com.yby.mall.storage.entity.PurchaseEntity;
import com.yby.mall.storage.service.PurchaseService;
import org.springframework.util.StringUtils;


@Service("purchaseService")
public class PurchaseServiceImpl extends ServiceImpl<PurchaseDao, PurchaseEntity> implements PurchaseService {

    @Autowired
    private PurchaseDao purchaseDao;

    @Override
    public R queryPage(Integer page, Integer limit,Integer status, String key) {
        PageHelper.startPage(page,limit);
        List<PurchaseEntity> list = purchaseDao.selectList(Wrappers.<PurchaseEntity>lambdaQuery()
                .like(!StringUtils.isEmpty(key), PurchaseEntity::getAssigneeName, key)
                .eq(!StringUtils.isEmpty(status), PurchaseEntity::getStatus, status)
        );
        return R.ok().put("page", PageUtils.restPage(list));
    }
}